package com.viettel.core.repo;

import java.io.Serializable;
import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.type.Type;

import com.viettel.core.common.utils.KPaging;
import com.viettel.core.common.utils.SpParam;
import com.viettel.core.exceptions.DataAccessException;

public interface IRepository {
	<T> T create(T object) throws DataAccessException;

	<T> List<T> createListObject(List<T> lstObject) throws DataAccessException;

	void update(Object object) throws DataAccessException;

	int executeSQLQuery(String sql, List<Object> params)
			throws DataAccessException;

	void delete(Object object) throws DataAccessException;

	<T> T getEntityById(Class<T> clazz, Serializable id)
			throws DataAccessException;

	<T> T getEntityByHQL(String hql, List<Object> params)
			throws DataAccessException;

	<T> T getEntityBySQL(Class<T> clazz, String sql, List<Object> params)
			throws DataAccessException;

	<T> T getEntityBySQL(Class<T> clazz, String sql, List<Object> params,
			List<Class<?>> synchronizedClass) throws DataAccessException;

	<T> T getFirstBySQL(Class<T> clazz, String sql, List<Object> params)
			throws DataAccessException;

	<T> T getFirstBySQL(Class<T> clazz, String sql, List<Object> params,
			List<Class<?>> synchronizedClass) throws DataAccessException;

	<T> List<T> getListByHQL(String hql, List<Object> params)
			throws DataAccessException;

	<T> List<T> getListByHQLPaginated(String selectHql, String countHql,
			List<Object> selectParams, List<Object> countParams,
			KPaging<T> paging) throws DataAccessException;

	<T> List<T> getListByHQLPaginated(String hql, List<Object> params,
			KPaging<T> paging) throws DataAccessException;

	<T> List<T> getListBySQL(Class<T> clazz, String sql, List<Object> params)
			throws DataAccessException;

	<T> List<T> getListBySQL(Class<T> clazz, String sql, List<Object> params,
			List<Class<?>> synchronizedClass) throws DataAccessException;

	<T> List<T> getListBySQLPaginated(Class<T> clazz, String selectSql,
			String countSql, List<Object> selectParams,
			List<Object> countParams, KPaging<T> paging)
			throws DataAccessException;

	<T> List<T> getListBySQLPaginated(Class<T> clazz, String selectSql,
			String countSql, List<Object> selectParams,
			List<Object> countParams, KPaging<T> paging,
			List<Class<?>> synchronizedClass) throws DataAccessException;

	<T> List<T> getListBySQLPaginated(Class<T> clazz, String sql,
			List<Object> params, KPaging<T> paging) throws DataAccessException;

	<T> List<T> getListBySQLPaginated(Class<T> clazz, String sql,
			List<Object> params, KPaging<T> paging,
			List<Class<?>> synchronizedClass) throws DataAccessException;

	<T> List<T> getListByQueryAndScalar(Class<T> clazz, String[] fieldNames,
			Type[] fieldTypes, String sql, List<Object> params)
			throws DataAccessException;

	<T> List<T> getListByQueryAndScalar(Class<T> clazz, String[] fieldNames,
			Type[] fieldTypes, String sql, List<Object> params,
			List<Class<?>> synchronizedClass) throws DataAccessException;

	<T> List<T> getListByQueryAndScalarPaginated(Class<T> clazz,
			String[] fieldNames, Type[] fieldTypes, String selectSql,
			String countSql, List<Object> selectParams,
			List<Object> countParams, KPaging<T> paging)
			throws DataAccessException;

	<T> List<T> getListByQueryAndScalarPaginated(Class<T> clazz,
			String[] fieldNames, Type[] fieldTypes, String selectSql,
			String countSql, List<Object> selectParams,
			List<Object> countParams, KPaging<T> paging,
			List<Class<?>> synchronizedClass) throws DataAccessException;

	int countByHQL(String countHql, List<Object> countParams)
			throws DataAccessException;

	int countBySQL(String countSql, List<Object> countParams)
			throws DataAccessException;

	int countBySQL(String countSql, List<Object> countParams,
			List<Class<?>> synchronizedClass) throws DataAccessException;

	<T> List<T> getListByNamedQuery(String namedQuerySQL, List<Object> params)
			throws DataAccessException;

	Object getObjectByQuery(String sql, List<Object> params)
			throws DataAccessException;

	Object getObjectByQuery(String sql, List<Object> params,
			List<Class<?>> synchronizedClass) throws DataAccessException;

	SessionFactory getSessionFactory();

	<T> List<T> getListByNamedQuery(Class<T> clazz, String namedQuerySQL,
			List<Object> params) throws DataAccessException;

	<T> List<T> getListBySQL(Class<T> clazz, String sql, List<Object> params,
			int maxResult) throws DataAccessException;

	<T> List<T> getListBySQL(Class<T> clazz, String sql, List<Object> params,
			List<Class<?>> synchronizedClass, Integer maxResult)
			throws DataAccessException;

	<T> List<T> getListByQueryAndScalar(Class<T> clazz, String[] fieldNames,
			Type[] fieldTypes, String sql, List<Object> params,
			List<Class<?>> synchronizedClass, Integer maxResult)
			throws DataAccessException;

	<T> List<T> getListByQueryAndScalar(Class<T> clazz, String[] fieldNames,
			Type[] fieldTypes, String sql, List<Object> params,
			Integer maxResult) throws DataAccessException;
	
	<T> List<T> getAll(Class<T> clazz) throws DataAccessException;
	
	void executeSP(String spName) throws DataAccessException;

	void executeSP(String spName, List<SpParam> inParams,
			List<SpParam> outParams) throws DataAccessException;
}
